const webpack = require('webpack');
//http://www.fly63.com/article/detial/7
//https://zh.nuxtjs.org/api/configuration-watchers
module.exports = {
  /*
  ** Headers of the page
  */
  head: {
    title: 'nuxt',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: 'Nuxt.js project' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  modules: [
    '@nuxtjs/axios',
    //'@nuxtjs/proxy'
  ],
  env:{
    proxyurl:'http://localhost:3000',
  },
  axios: {
    proxy: true
  },
  proxy: [
      [
        '/api', 
        { 
          target: 'http://localhost:3000', // api主机
          pathRewrite: { '^/api' : '/api' }
        }
    ]
  ],
  loading: { color: '#3B8070' },
  //loading:'./components/loading.vue',
  // cache: {
  //   max: 1000,//缓存数组最大数
  //   maxAge: 15*60*1000//15 minutes
  // },
  // render: {
  //   bundleRenderer: {
  //     cache: require('lru-cache')({
  //       max: 1000,
  //       maxAge: 1000 * 60 * 15
  //     })
  //   }
  // },
  css:[
    '~assets/css/main.css',
    'iview/dist/styles/iview.css',
    { src: './assets/css/main.less', lang: 'less' } 
  ],
  plugins: [
    '~plugins/vue-notifications',
    '~/plugins/components',
    '~/plugins/filters',
    "~/plugins/iview",
    '~/plugins/vue-quill-editor'
  ],
  router: {
    // 在每页渲染前运行 middleware/user-agent.js 中间件的逻辑
    middleware: [
      //'user-agent',
    ]
  },
  build: {
    vendor: [
      'axios',
      //'~/plugins/vue-notifications',
      //'./tools/axios'
    ],
    babel: {
      //presets: ['es2015', 'stage-0']
    },
    // filenames: {
    //   vendor: 'vendor.[hash].js',
    //   app: 'app.[chunkhash].js'
    // },
    loaders:[

    ],
    plugins: [
      new webpack.DefinePlugin({
        'process.VERSION': require('./package.json').version
      })
    ],
    extend (config, { isDev, isClient }) {
      if (isDev && isClient) {
        // config.module.rules.push({
        //   enforce: 'pre',
        //   test: /\.(js|vue)$/,
        //   loader: 'eslint-loader',
        //   exclude: /(node_modules)/
        // })
      }
    }
    
  }
}
